package com.oa.item.dao;

import org.apache.ibatis.jdbc.SQL;

import com.oa.item.entity.ItemWithBLOBs;

public class ItemSqlProvider {

    public String insertSelective(ItemWithBLOBs record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("item");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getItemName() != null) {
            sql.VALUES("item_name", "#{itemName,jdbcType=VARCHAR}");
        }
        
        if (record.getItemTime() != null) {
            sql.VALUES("item_time", "#{itemTime,jdbcType=VARCHAR}");
        }
        
        if (record.getItemMoney() != null) {
            sql.VALUES("item_money", "#{itemMoney,jdbcType=VARCHAR}");
        }
        
        if (record.getItemHead() != null) {
            sql.VALUES("item_head", "#{itemHead,jdbcType=VARCHAR}");
        }
        
        if (record.getItemLiable() != null) {
            sql.VALUES("item_liable", "#{itemLiable,jdbcType=VARCHAR}");
        }
        
        if (record.getItemHandlers() != null) {
            sql.VALUES("item_handlers", "#{itemHandlers,jdbcType=VARCHAR}");
        }
        
        if (record.getItemSec() != null) {
            sql.VALUES("item_sec", "#{itemSec,jdbcType=VARCHAR}");
        }
        
        if (record.getItemWhodo() != null) {
            sql.VALUES("item_whodo", "#{itemWhodo,jdbcType=VARCHAR}");
        }
        
        if (record.getSpar() != null) {
            sql.VALUES("spar", "#{spar,jdbcType=VARCHAR}");
        }
        
        if (record.getItemDetail() != null) {
            sql.VALUES("item_detail", "#{itemDetail,jdbcType=LONGVARCHAR}");
        }
        
        if (record.getItemDoplan() != null) {
            sql.VALUES("item_doplan", "#{itemDoplan,jdbcType=LONGVARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(ItemWithBLOBs record) {
        SQL sql = new SQL();
        sql.UPDATE("item");
        
        if (record.getItemName() != null) {
            sql.SET("item_name = #{itemName,jdbcType=VARCHAR}");
        }
        
        if (record.getItemTime() != null) {
            sql.SET("item_time = #{itemTime,jdbcType=VARCHAR}");
        }
        
        if (record.getItemMoney() != null) {
            sql.SET("item_money = #{itemMoney,jdbcType=VARCHAR}");
        }
        
        if (record.getItemHead() != null) {
            sql.SET("item_head = #{itemHead,jdbcType=VARCHAR}");
        }
        
        if (record.getItemLiable() != null) {
            sql.SET("item_liable = #{itemLiable,jdbcType=VARCHAR}");
        }
        
        if (record.getItemHandlers() != null) {
            sql.SET("item_handlers = #{itemHandlers,jdbcType=VARCHAR}");
        }
        
        if (record.getItemSec() != null) {
            sql.SET("item_sec = #{itemSec,jdbcType=VARCHAR}");
        }
        
        if (record.getItemWhodo() != null) {
            sql.SET("item_whodo = #{itemWhodo,jdbcType=VARCHAR}");
        }
        
        if (record.getSpar() != null) {
            sql.SET("spar = #{spar,jdbcType=VARCHAR}");
        }
        
        if (record.getItemDetail() != null) {
            sql.SET("item_detail = #{itemDetail,jdbcType=LONGVARCHAR}");
        }
        
        if (record.getItemDoplan() != null) {
            sql.SET("item_doplan = #{itemDoplan,jdbcType=LONGVARCHAR}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}